package com.xsy.android.compose.we.component.ui.navgation

import androidx.compose.runtime.Composable
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import com.xsy.android.compose.we.component.ui.compose.MainPage
import com.xsy.android.compose.we.component.ui.page.chat.ChatPage

/**
 *@author: xiaosy
 *时间: 2024/6/27
 *@Description: java类作用描述
 *@Version: 1.0
 **/
@Composable
fun NavGraph() {
    val navController = rememberNavController()
    NavHost(navController = navController, startDestination = "main") {

        composable("main") {
            MainPage(navController)
        }
        composable("chat_page/{index}", arguments = listOf(navArgument("index"){ type = NavType.IntType})) {backStackEntry ->
            val index = backStackEntry.arguments?.getInt("index") ?: 0
            ChatPage(navController = navController,index = index)
        }

    }

}